package com.ty.dictionaries.controller;

import com.ty.dictionaries.service.IDictService;
import com.ty.utils.R;
import com.ty.utils.pojo.Dict;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 * 数据管理表 前端控制器
 * </p>
 *
 * @author xinyu
 * @since 2023-02-20
 */


@RestController
@RequestMapping("/dict")
@Api(tags = "上传图片")
public class DictController {
    //注入IDictService
    @Autowired
    private IDictService dictService;

    //查询所有父类数据字典
    @ApiOperation(value="")
    @GetMapping("/findChlidData/{id}")
    public R findChlidData(@PathVariable("id") Long id){
        List<Dict> list = dictService.findChlidData(id );
        return R.ok().data("list",list);
    }
    /*数据字典导出*/
    @ApiOperation(value="导出")
    @GetMapping(value = "/exportData")
    public void exportData(HttpServletResponse response) {
        dictService.exportData(response);
    }

    //数据字典导入
    @ApiOperation(value = "导入")
    @PostMapping("/importData")
    public R importData(MultipartFile file){
        dictService.importData(file);
        return R.ok();
    }

}
